<?php


namespace App\Http\Controllers\Api;


use App\Models\MiniProgramBottomTab;
use App\Models\MiniProgramSpecial;
use App\Services\SpecialService;
use Illuminate\Http\Request;

class SpecialController extends Controller
{
    public function module(Request $request, SpecialService $service)
    {
        $type = $request->input('type', 'index');

        $list = $service->getSpecialData($this->getMiniType(), $type);

        return $this->_success([
            'list' => $list
        ]);
    }

    public function bottomTab(Request $request)
    {
        $list = MiniProgramBottomTab::with(['jump' => function ($q) {
            return $q->where('is_show', 1);
        }])->where([
            'mini_type' => $this->getMiniType(),
            'is_show'   => true,
        ])->orderByDesc('sort')->orderByDesc('id')->get();

        return $this->_success([
            'list' => $list
        ]);
    }
}
